home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / zoc110.arj / ZOC / SCRIPT / SAMPLES / 7_CALBBS < prev   
Text File  |  1994-01-09  |  5KB  |  195 lines

  1.     #  This is a non-functional skeleton for creating an autologin 
  2.     #  script. However you might not need it, since simple autologins 
  3.     #  can be achieved without script programming using the autologin 
  4.     #  feature of the phone book.
  5.  
  6.     #  Scenario:
  7.     #    Let's assume Zaphod Beeblebrox uses the Megadodo bbs on Ursa 
  8.     #    Minor Beta to download new messages and upload the replys that 
  9.     #      he wrote offline. 
  10.     #    This script calls the bbs and eventually tries again until it
  11.     #    gets a CONNECT. Then it goes to the main menu where it downloads
  12.     #    a new mail packet and, if available, uploads Zaphod's replys.
  13.  
  14.  
  15.  
  16.     #  Prevent users from accidently dialling long distance to Ursa Minor Beta
  17.     request "Are you sure you want to make a call across the universe?" "No" "No"
  18.     goto finish
  19.  
  20.  
  21.     #  To test your own script, change the next line to 'debug 1'
  22.     debug 0
  23.  
  24.  
  25.     #  Set a few values (999 is the prefix for inter galactical calls :-)
  26.     setn  waittime 10            ;# time between dials
  27.     setn  maxtry   42            ;# max number of trys
  28.     seta  phone    "999-9283748742893478" ;# phone number to call
  29.  
  30.  
  31.     #  Init the modem (and fail if no OK received within 5 seconds)
  32.     timeout 5
  33.     send "ATZ"
  34.     wait "OK"
  35.     ifbrk goto fail    
  36.  
  37.     #   Reset counter, clear screen
  38.     setn counter 1
  39.     cls
  40.  
  41.  
  42.     #   MAIN LOOP
  43.     #
  44.  
  45. :loop0
  46.     #  Dial and see what happens
  47.     dial "%phone%"
  48.  
  49.     #  Set timeout to 90sec. and wait for a line of text to come
  50.     timeout 90
  51. :loop1
  52.     waitline
  53.  
  54.     #  if something arrived save incoming line to variable 
  55.     #  (lastline might change duringprocessing)
  56.     ifnbrk seta last "%lastline%"
  57.  
  58.     #  else
  59.     #  if WAITLINE timed out, set our variable to TIMEOUT
  60.     ifbrk  seta last "TIMEOUT"
  61.  
  62.     #  Set text compare to non exact matching (that is CONNECT=CONNECT 1200)
  63.     exact    0
  64.  
  65.     #  compare to for CONNECT or CARRIER and if equal, log in
  66.     compa    "%last%" WITH CONNECT
  67.     ifequ    goto login    
  68.  
  69.     compa    "%last%" WITH CARRIER
  70.     ifequ    goto login    
  71.  
  72.  
  73.     #  Try again for BUSY, NO CARRIER
  74.     compa    "%last%" WITH BUSY
  75.     ifequ    goto SomeMore    
  76.  
  77.     compa    "%last%" WITH "NO CARRIER"
  78.     ifequ    goto SomeMore    
  79.  
  80.  
  81.     #  for TIMEOUT hang up
  82.     compa    "%last%" WITH "NO CARRIER"
  83.     ifequ    hangup
  84.  
  85.  
  86.     #   Ignore anything else (Zyxels say 'RINGING' or V42 say 'PROCOL xxx')
  87.     #  and wait for something we know
  88.     goto loop1
  89.  
  90.     #  Increment counter and eventually try again
  91.     #
  92. :SomeMore
  93.     #  ... wait and see if we ...
  94.     delay    %waittime%
  95.  
  96.     #  ... want to try again?
  97.     inc     counter
  98.     compn    %counter% with %maxtry%
  99.     iflow    goto loop0
  100.     ifequ    goto loop0
  101.  
  102.     #   No success after %maxtry% tries
  103.     goto    fail
  104.  
  105.  
  106.  
  107.     ##################
  108.     #  LOGIN        #
  109.     ##################
  110.  
  111. :login
  112.     #  Make a bit noise
  113.     beep 3
  114.     writeln "^M^J^J^MConnection established!!"
  115.     timeout 30
  116.  
  117.     #  log in
  118.     wait  "Name"
  119.     send  "Zaphod Beeblebroox^m"
  120.     wait  "Password"
  121.     send  "heart of gold^m"
  122.  
  123.  
  124.     #  care for the stuff they use to make script programming 
  125.     #  a bit harder (respond will be active whenever
  126.     #  the script processes a DELAY, WAIT or WAITLINE)
  127.     respond "your birth date" "11/11/11^m"
  128.     respond "press <enter> to continue" "^m"
  129.  
  130.     #  Wait for the main menu, go to the mail area and
  131.     #  request to download a mail packet
  132.     timeout 60
  133.     wait "your choice"
  134.     send "m^M"
  135.  
  136.     wait "your choice"
  137.     send "d^M"
  138.  
  139.     wait "file transfer protocol"
  140.     send "z^M"
  141.  
  142.     wait "are you sure"
  143.     send "y^M"
  144.  
  145.  
  146.     #  We could use the download command, but it's easier just to 
  147.     #  let autodownload jump in during a WAIT. So wait for the
  148.     #  'download finished' message and let autodownload care for
  149.     #  the rest 
  150.     
  151.     timeout 600          ;#   download could take a long time
  152.     wait "finished"
  153.  
  154.     wait "your choice"
  155.  
  156.  
  157.     #  Do the same for upload. To find out if an reply file exists
  158.     #  try to open it for reading.
  159.     openfile "hitchh.rep" "r"
  160.     compa "%lastline%" with "##OK##"
  161.     ifnequ goto logout
  162.     closefile 
  163.  
  164.     send "u^M"
  165.  
  166.     wait "file transfer protocol"
  167.     send "z^M"
  168.  
  169.     wait "are you sure"
  170.     send "y^M"
  171.  
  172.     timeout 600          ;#   upload could take a long time
  173.     wait "finished"
  174.  
  175.     #  after up/download go to the main menu and log out
  176. :logout
  177.        #  main menu (send ESC)
  178.     send "^["
  179.  
  180.        #  log out 
  181.     wait "your choice"
  182.     send "L"
  183.  
  184.  
  185.     ##################
  186.     #  THE END       #
  187.     ##################
  188. :finish
  189.     exit
  190.  
  191. :fail
  192.     writeln "ERROR"
  193.     exit
  194.  
  195.